#
faces = [{'faceId': 'f9984002-da51-4848-9d6f-2b6704ef6d9c',
  'faceRectangle': {'top': 118, 'left': 144, 'width': 88, 'height': 88},
  'faceAttributes': {'smile': 0.813,
   'headPose': {'pitch': -3.4, 'roll': 1.4, 'yaw': 9.4},
   'gender': 'male',
   'age': 19.0,
   'facialHair': {'moustache': 0.1, 'beard': 0.1, 'sideburns': 0.1},
   'glasses': 'NoGlasses',
   'emotion': {'anger': 0.0,
    'contempt': 0.003,
    'disgust': 0.0,
    'fear': 0.0,
    'happiness': 0.813,
    'neutral': 0.184,
    'sadness': 0.0,
    'surprise': 0.0},
   'blur': {'blurLevel': 'low', 'value': 0.21},
   'exposure': {'exposureLevel': 'overExposure', 'value': 0.81},
   'noise': {'noiseLevel': 'low', 'value': 0.01},
   'makeup': {'eyeMakeup': False, 'lipMakeup': False},
   'accessories': [],
   'occlusion': {'foreheadOccluded': False,
    'eyeOccluded': False,
    'mouthOccluded': False},
   'hair': {'bald': 0.18,
    'invisible': False,
    'hairColor': [{'color': 'brown', 'confidence': 0.95},
     {'color': 'black', 'confidence': 0.93},
     {'color': 'other', 'confidence': 0.23},
     {'color': 'blond', 'confidence': 0.23},
     {'color': 'gray', 'confidence': 0.21},
     {'color': 'red', 'confidence': 0.15},
     {'color': 'white', 'confidence': 0.0}]}}},
 {'faceId': '842a1b59-d5ff-42b7-8536-ab866028d2c1',
  'faceRectangle': {'top': 117, 'left': 376, 'width': 64, 'height': 64},
  'faceAttributes': {'smile': 0.456,
   'headPose': {'pitch': -1.1, 'roll': -0.2, 'yaw': 6.6},
   'gender': 'female',
   'age': 22.0,
   'facialHair': {'moustache': 0.0, 'beard': 0.0, 'sideburns': 0.0},
   'glasses': 'NoGlasses',
   'emotion': {'anger': 0.0,
    'contempt': 0.001,
    'disgust': 0.0,
    'fear': 0.0,
    'happiness': 0.456,
    'neutral': 0.542,
    'sadness': 0.001,
    'surprise': 0.0},
   'blur': {'blurLevel': 'low', 'value': 0.16},
   'exposure': {'exposureLevel': 'goodExposure', 'value': 0.58},
   'noise': {'noiseLevel': 'low', 'value': 0.01},
   'makeup': {'eyeMakeup': False, 'lipMakeup': True},
   'accessories': [],
   'occlusion': {'foreheadOccluded': False,
    'eyeOccluded': False,
    'mouthOccluded': False},
   'hair': {'bald': 0.08,
    'invisible': False,
    'hairColor': [{'color': 'black', 'confidence': 1.0},
     {'color': 'other', 'confidence': 0.63},
     {'color': 'brown', 'confidence': 0.46},
     {'color': 'gray', 'confidence': 0.39},
     {'color': 'blond', 'confidence': 0.03},
     {'color': 'red', 'confidence': 0.01},
     {'color': 'white', 'confidence': 0.0}]}}},
 {'faceId': '6cd77b6d-f8fc-4ee5-be51-f915bdbc210b',
  'faceRectangle': {'top': 41, 'left': 676, 'width': 52, 'height': 52},
  'faceAttributes': {'smile': 1.0,
   'headPose': {'pitch': 3.0, 'roll': -1.3, 'yaw': -0.6},
   'gender': 'male',
   'age': 25.0,
   'facialHair': {'moustache': 0.1, 'beard': 0.1, 'sideburns': 0.1},
   'glasses': 'ReadingGlasses',
   'emotion': {'anger': 0.0,
    'contempt': 0.0,
    'disgust': 0.0,
    'fear': 0.0,
    'happiness': 1.0,
    'neutral': 0.0,
    'sadness': 0.0,
    'surprise': 0.0},
   'blur': {'blurLevel': 'low', 'value': 0.0},
   'exposure': {'exposureLevel': 'goodExposure', 'value': 0.66},
   'noise': {'noiseLevel': 'low', 'value': 0.07},
   'makeup': {'eyeMakeup': False, 'lipMakeup': False},
   'accessories': [{'type': 'glasses', 'confidence': 1.0}],
   'occlusion': {'foreheadOccluded': False,
    'eyeOccluded': False,
    'mouthOccluded': False},
   'hair': {'bald': 0.06,
    'invisible': False,
    'hairColor': [{'color': 'black', 'confidence': 0.98},
     {'color': 'brown', 'confidence': 0.96},
     {'color': 'other', 'confidence': 0.22},
     {'color': 'gray', 'confidence': 0.21},
     {'color': 'red', 'confidence': 0.09},
     {'color': 'blond', 'confidence': 0.08},
     {'color': 'white', 'confidence': 0.0}]}}},
 {'faceId': '5f96f25b-4969-49d6-ab21-998fb3b07f7d',
  'faceRectangle': {'top': 69, 'left': 445, 'width': 52, 'height': 52},
  'faceAttributes': {'smile': 1.0,
   'headPose': {'pitch': 0.2, 'roll': 2.6, 'yaw': 1.5},
   'gender': 'female',
   'age': 23.0,
   'facialHair': {'moustache': 0.0, 'beard': 0.0, 'sideburns': 0.0},
   'glasses': 'NoGlasses',
   'emotion': {'anger': 0.0,
    'contempt': 0.0,
    'disgust': 0.0,
    'fear': 0.0,
    'happiness': 1.0,
    'neutral': 0.0,
    'sadness': 0.0,
    'surprise': 0.0},
   'blur': {'blurLevel': 'low', 'value': 0.0},
   'exposure': {'exposureLevel': 'goodExposure', 'value': 0.56},
   'noise': {'noiseLevel': 'medium', 'value': 0.33},
   'makeup': {'eyeMakeup': False, 'lipMakeup': False},
   'accessories': [],
   'occlusion': {'foreheadOccluded': False,
    'eyeOccluded': False,
    'mouthOccluded': False},
   'hair': {'bald': 0.11,
    'invisible': False,
    'hairColor': [{'color': 'black', 'confidence': 1.0},
     {'color': 'brown', 'confidence': 0.81},
     {'color': 'other', 'confidence': 0.41},
     {'color': 'gray', 'confidence': 0.37},
     {'color': 'blond', 'confidence': 0.03},
     {'color': 'red', 'confidence': 0.02},
     {'color': 'white', 'confidence': 0.0}]}}},
 {'faceId': '8bb0d7e8-008f-43d5-b649-0c46c69b15b4',
  'faceRectangle': {'top': 95, 'left': 238, 'width': 51, 'height': 51},
  'faceAttributes': {'smile': 0.981,
   'headPose': {'pitch': 7.2, 'roll': 1.2, 'yaw': 2.6},
   'gender': 'female',
   'age': 18.0,
   'facialHair': {'moustache': 0.0, 'beard': 0.0, 'sideburns': 0.0},
   'glasses': 'ReadingGlasses',
   'emotion': {'anger': 0.0,
    'contempt': 0.0,
    'disgust': 0.0,
    'fear': 0.0,
    'happiness': 0.981,
    'neutral': 0.019,
    'sadness': 0.0,
    'surprise': 0.0},
   'blur': {'blurLevel': 'low', 'value': 0.07},
   'exposure': {'exposureLevel': 'goodExposure', 'value': 0.69},
   'noise': {'noiseLevel': 'medium', 'value': 0.48},
   'makeup': {'eyeMakeup': False, 'lipMakeup': False},
   'accessories': [{'type': 'glasses', 'confidence': 1.0}],
   'occlusion': {'foreheadOccluded': False,
    'eyeOccluded': False,
    'mouthOccluded': False},
   'hair': {'bald': 0.11,
    'invisible': False,
    'hairColor': [{'color': 'black', 'confidence': 0.98},
     {'color': 'brown', 'confidence': 0.86},
     {'color': 'other', 'confidence': 0.4},
     {'color': 'gray', 'confidence': 0.36},
     {'color': 'blond', 'confidence': 0.09},
     {'color': 'red', 'confidence': 0.08},
     {'color': 'white', 'confidence': 0.0}]}}},
 {'faceId': 'a511e7e1-ec6d-4123-9f0b-734e036cf242',
  'faceRectangle': {'top': 94, 'left': 540, 'width': 48, 'height': 48},
  'faceAttributes': {'smile': 1.0,
   'headPose': {'pitch': -7.7, 'roll': 5.0, 'yaw': 6.9},
   'gender': 'female',
   'age': 19.0,
   'facialHair': {'moustache': 0.0, 'beard': 0.0, 'sideburns': 0.0},
   'glasses': 'NoGlasses',
   'emotion': {'anger': 0.0,
    'contempt': 0.0,
    'disgust': 0.0,
    'fear': 0.0,
    'happiness': 1.0,
    'neutral': 0.0,
    'sadness': 0.0,
    'surprise': 0.0},
   'blur': {'blurLevel': 'low', 'value': 0.08},
   'exposure': {'exposureLevel': 'goodExposure', 'value': 0.65},
   'noise': {'noiseLevel': 'low', 'value': 0.08},
   'makeup': {'eyeMakeup': False, 'lipMakeup': False},
   'accessories': [],
   'occlusion': {'foreheadOccluded': False,
    'eyeOccluded': False,
    'mouthOccluded': False},
   'hair': {'bald': 0.1,
    'invisible': False,
    'hairColor': [{'color': 'black', 'confidence': 1.0},
     {'color': 'brown', 'confidence': 0.88},
     {'color': 'other', 'confidence': 0.35},
     {'color': 'gray', 'confidence': 0.33},
     {'color': 'blond', 'confidence': 0.05},
     {'color': 'red', 'confidence': 0.04},
     {'color': 'white', 'confidence': 0.0}]}}}]

# 创建字典
glasses = {}
smile = {}
hairColor = {}
age = {}
gender = {}

# 将人脸信息加入字典
count = 0
while count < len(faces):
    glasses["Person{}".format(count + 1)] = faces[count]['faceAttributes']['glasses']
    smile["Person{}".format(count + 1)] = faces[count]['faceAttributes']['smile']
    hairColor["Person{}".format(count + 1)] = faces[count]['faceAttributes']['hair']['hairColor'][0]['color']
    age["Person{}".format(count + 1)] = faces[count]['faceAttributes']['age']
    gender["Person{}".format(count + 1)] = faces[count]['faceAttributes']['gender']
    count += 1

# 打印
print("眼镜：", glasses)
print("微笑指数：", smile)
print("头发颜色：", hairColor)
print("年龄：", age)
print("性别：", gender)

#运行结果如下：
'''
眼镜： {'Person1': 'NoGlasses', 'Person2': 'NoGlasses', 'Person3': 'ReadingGlasses', 'Person4': 'NoGlasses', 'Person5': 'ReadingGlasses', 'Person6': 'NoGlasses'}
微笑指数： {'Person1': 0.813, 'Person2': 0.456, 'Person3': 1.0, 'Person4': 1.0, 'Person5': 0.981, 'Person6': 1.0}
头发颜色： {'Person1': 'brown', 'Person2': 'black', 'Person3': 'black', 'Person4': 'black', 'Person5': 'black', 'Person6': 'black'}
年龄： {'Person1': 19.0, 'Person2': 22.0, 'Person3': 25.0, 'Person4': 23.0, 'Person5': 18.0, 'Person6': 19.0}
性别： {'Person1': 'male', 'Person2': 'female', 'Person3': 'male', 'Person4': 'female', 'Person5': 'female', 'Person6': 'female'}
'''